package com.xxl.sso.core.util;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;

import com.fasterxml.jackson.databind.ObjectMapper;

public class ResponseUtils {

	public static void writeResponse(HttpServletResponse response, Object result) {
		response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
		ObjectMapper mapper = new ObjectMapper();
		try {
			response.getWriter().write(mapper.writeValueAsString(result));
		} catch (IOException e) {
			throw new IllegalStateException(e);
		}
	}
	
}
